<?php
namespace app\adminapiv3\controller;

/**
 * @name: 服务器配置接口
 * @Param: 
 * @Description: 
 * @Author: foo
 * @Date: 2019-10-23 13:36:31
 */
use app\adminapiv3\service;
class Config extends Base
{
    /**
     * @name: 客户端获取配置
     * @Param: 
     * @Description: 
     * @Author: foo
     * @Date: 2019-09-20 16:28:09
     */
    function get ($configType)
    {
        $Config = new service\Config();
        $this->toDo([$Config, 'checkConfigType'], [$configType]);

        $data = $this->toDo([$Config, 'configFget'], [$configType]);

        $this->jsonOutPut($data);
    }

    /**
     * @name: 客户端更新配置
     * @Param: 
     * @Description: 
     * @Author: foo
     * @Date: 2019-09-20 16:28:20
     */
    function modify ($configType)
    {
        $Config = new service\Config();
        $fieldData = $this->toDo([$Config, 'checkConfigType'], [$configType]);
        $updateData = [];

        foreach ($fieldData as $v)
        {
            if($configType == 'webPageAlertsManage'){
                $updateData[$v] = $this->filterInput($v, 'post');//接受参数
            }else{
                $updateData[$v] = $this->filterInput($v.'*', 'post');//接受参数
            }
        }

        $this->toDo([$Config, 'configFwrite'], [$updateData]);
        
        $this->jsonOutPut();
    }
}